class_name BaseComponent
extends Node2D

@export var component_name:String = ""
# 初始化优先级，越小越早初始化
@export var priority:int = 0
var cur_entity
var inited:bool = false

func init_component(entity):
	inited = true
	cur_entity = entity
func get_cur_entity():
	return cur_entity
# 包含自身和父级
static func get_component_in_parent(cur_node:Node,type_name:String)->Node:
	var component = null
	var pattern:String = type_name
	while cur_node != null:
		if cur_node.name.match(pattern):
			component = cur_node
			break
		cur_node = cur_node.get_parent()
	return component
# 只包含子级
static func get_component_in_childrean(cur_node:Node,type_name:String)->Node:
	var pattern:String = type_name
	return cur_node.find_child(pattern,true,true)
